package com.ktgj.service.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.service.domain.KtserviceViphallMeal;
import com.ktgj.service.service.IKtserviceViphallMealService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 贵宾厅套餐Controller
 * 
 * @author ruoyi
 * @date 2022-05-30
 */
@RestController
@RequestMapping("/meal")
public class KtserviceViphallMealController extends BaseController
{
    @Autowired
    private IKtserviceViphallMealService ktserviceViphallMealService;

    /**
     * 查询贵宾厅套餐列表
     */
    @PreAuthorize(hasPermi = "system:meal:list")
    @GetMapping("/list")
    public TableDataInfo list(KtserviceViphallMeal ktserviceViphallMeal)
    {
        startPage();
        List<KtserviceViphallMeal> list = ktserviceViphallMealService.selectKtserviceViphallMealList(ktserviceViphallMeal);
        return getDataTable(list);
    }

    /**
     * 导出贵宾厅套餐列表
     */
    @PreAuthorize(hasPermi = "system:meal:export")
    @Log(title = "贵宾厅套餐", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, KtserviceViphallMeal ktserviceViphallMeal) throws IOException
    {
        List<KtserviceViphallMeal> list = ktserviceViphallMealService.selectKtserviceViphallMealList(ktserviceViphallMeal);
        ExcelUtil<KtserviceViphallMeal> util = new ExcelUtil<KtserviceViphallMeal>(KtserviceViphallMeal.class);
        util.exportExcel(response, list, "贵宾厅套餐数据");
    }

    /**
     * 获取贵宾厅套餐详细信息
     */
    @PreAuthorize(hasPermi = "system:meal:query")
    @GetMapping(value = "/{viphallMealId}")
    public AjaxResult getInfo(@PathVariable("viphallMealId") Long viphallMealId)
    {
        return AjaxResult.success(ktserviceViphallMealService.selectKtserviceViphallMealById(viphallMealId));
    }

    /**
     * 新增贵宾厅套餐
     */
    @PreAuthorize(hasPermi = "system:meal:add")
    @Log(title = "贵宾厅套餐", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody KtserviceViphallMeal ktserviceViphallMeal)
    {
        return toAjax(ktserviceViphallMealService.insertKtserviceViphallMeal(ktserviceViphallMeal));
    }

    /**
     * 修改贵宾厅套餐
     */
    @PreAuthorize(hasPermi = "system:meal:edit")
    @Log(title = "贵宾厅套餐", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody KtserviceViphallMeal ktserviceViphallMeal)
    {
        return toAjax(ktserviceViphallMealService.updateKtserviceViphallMeal(ktserviceViphallMeal));
    }

    /**
     * 删除贵宾厅套餐
     */
    @PreAuthorize(hasPermi = "system:meal:remove")
    @Log(title = "贵宾厅套餐", businessType = BusinessType.DELETE)
	@DeleteMapping("/{viphallMealIds}")
    public AjaxResult remove(@PathVariable Long[] viphallMealIds)
    {
        return toAjax(ktserviceViphallMealService.deleteKtserviceViphallMealByIds(viphallMealIds));
    }
}
